package org.shoukaiseki.inittable.utils;


import org.shoukaiseki.inittable.domain.TableColumnInfo;
import org.shoukaiseki.inittable.domain.TableConstraintInfo;
import org.shoukaiseki.inittable.domain.TableIndexInfo;
import org.shoukaiseki.inittable.domain.TableTriggerInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * org.shoukaiseki.inittable.utils.TableInfoUtils
 * <br>
 *
 * @author shoukaiseki ブログ http://www.shoukaiseki.top/<br> E-メール jiang28555@Gmail.com<br>
 * @date 2022-10-07 14:08:52<br>
 */
public class TableInfoUtils {

    public static List<TableColumnInfo> tableColumns(TableColumnInfoBuilder... tableColumnInfoBuilders){
        List<TableColumnInfo> list=new ArrayList<>();
        for (TableColumnInfoBuilder tableColumnInfo : tableColumnInfoBuilders) {
            if(tableColumnInfo!=null){
                list.add(tableColumnInfo.build());
            }
        }
        return list;
    }


    public static List<TableIndexInfo> tableIndexs(TableIndexInfoBuilder... tableIndexInfoBuilders){
        List<TableIndexInfo> list=new ArrayList<>();
        if(tableIndexInfoBuilders==null){
            return list;
        }
        for (TableIndexInfoBuilder indexInfoBuilder : tableIndexInfoBuilders) {
            if(indexInfoBuilder!=null){
                list.add(indexInfoBuilder.build());
            }
        }
        return list;
    }

    public static List<TableConstraintInfo> TableConstraints(TableConstraintInfoBuilder... builders){
        List<TableConstraintInfo> list=new ArrayList<>();
        if(builders==null){
            return list;
        }
        for (TableConstraintInfoBuilder builder : builders) {
            if(builder!=null){
                list.add(builder.build());
            }
        }
        return list;
    }

    public static List<TableTriggerInfo> tableTriggers(TableTriggerInfoBuilder... tableTriggerInfoBuilders){
        List<TableTriggerInfo> list=new ArrayList<>();
        for (TableTriggerInfoBuilder tableTriggerInfoBuilder : tableTriggerInfoBuilders) {
            if(tableTriggerInfoBuilder!=null){
                list.add(tableTriggerInfoBuilder.build());
            }
        }
        return list;
    }

}
